<div class="task1"><?php
$seg = $this->uri->segment('3');
$this->db->where('tbl_card.car_id', $seg);
$this->db->select('*, tbl_card.car_type_id AS cartype_id');
$this->db->from('tbl_card');
$this->db->join('tbl_pricecard', 'tbl_card.car_id=tbl_pricecard.car_id');
// $this->db->join('tbl_car_type','tbl_car_type.car_type_id=tbl_card.car_type_id');
$query = $this->db->get();
echo form_open('card/edit/' . $this->uri->segment('3'));
echo '<div class="form-wrapper" style="width:60%;padding:10px; borde:0px solid #000;margin:0 auto;">';
echo '<fieldset>';
echo '<legend align="center"><div class="heading" style="color:#006600;font-size:24px;">Edit Form</div></legend>';
echo ' <div style="float: right;width:auto;height: auto;">' . anchor("card/manager", img("images/user_images/cancel.png")) . '</div>';
echo '<table align="center">';
echo '<tr>';
echo '<td>CardName</td>';
foreach ($query->result() as $rows) {
    echo '<td>' . form_input(array('name' => 'txt_name', 'value' => $rows->car_name)) . '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>Card Type</td>';
    echo '<td>';

    echo '<select name="card_type">';
    echo '<option value="">-please select-</option>';
    $this->db->select('*');
    $selectdata = $this->db->get('tbl_car_type');
    foreach ($selectdata->result() as $type) {
        $sel = ($rows->cartype_id == $type->car_type_id) ? ' selected="selected"' : '';
        echo'<option value="' . $type->car_type_id . '"' . $sel . '>' . $type->car_type_name . '</option>';
    }

    echo '</select> ';
    echo '</td>';
    echo '<tr>';
    echo '<td>Price Khmer</td>';

    echo '<td>' . form_input(array('name' => 'txt_pricek', 'value' => $rows->price_K)) . '</td>';

    echo '</tr>';
    echo '<tr>';
    echo '<td>Price Volunteer</td>';
    echo '<td>' . form_input(array('name' => 'txt_pricev', 'value' => $rows->price_V)) . '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td>Price TCM</td>';
    echo '<td>' . form_input(array('name' => 'txt_price_other', 'value' => $rows->price_other)) . '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<tr>';
    echo '<td valign="top">Quantity&nbsp;<span>*</span></td>';
    echo '<td>' . form_input(array('name' => 'txt_quantity', 'value' => $rows->car_quantity)) . '</td>';
    echo '</tr>';
    echo '<td>Description</td>';
    echo '<td>' . form_textarea(array('name' => 'txt_description', 'cols' => '50', 'rows' => '8', 'value' => $rows->car_description)) . '</td>';
    echo '</tr>';
    echo '<tr>';
    echo '<td></td>';
    echo '<td>' . form_submit('btn_update', 'Update') . form_reset('btn_reset', 'Reset') . '</td>';
    echo '</tr>';
}
echo '</table>';
echo '</fieldset>';
echo '</div>';

echo form_close();
?></div>
